/**
 * 错误码
 */
export class ErrorCode {
    code: number;
    message: string;
    private static codeMap = {};

    constructor(code: number, msg: string) {
        this.code = code;
        this.message = msg;
        ErrorCode.codeMap[code] = this;
    }

    public static valueOf(code: number): ErrorCode {
        return this.codeMap[code];
    }

}

export const SUCCESS = new ErrorCode(200, '成功');
export const SERVER_ERROR = new ErrorCode(10000, '服务器异常');
export const AUTH_ERROR = new ErrorCode(10001, '认证失败');
export const PARAMS_ERROR = new ErrorCode(10002, '参数错误');
export const JSON_PARSE_ERROR = new ErrorCode(10003, 'Json解析错误');
export const MSG_REQ_ERROR = new ErrorCode(10004, '短信服务请求失败');
export const MSG_REQ_TOO_FAST_ERROR = new ErrorCode(10005, '短信请求太快');
export const USER_NOT_REGISTER = new ErrorCode(10006, '用户尚未注册');
export const MSG_CODE_ERROR = new ErrorCode(10007, '验证码错误或过期');
export const AUTH_PASSWORD_ERROR = new ErrorCode(10008, '密码错误');
export const AUTH_USER_EXIST = new ErrorCode(10009, '用户已经存在');

/*
export enum ErrorCodes {
    SUCCESS,
    SERVER_ERROR,
    AUTH_ERROR,
    PARAMS_ERROR,
    JSON_PARSE_ERROR,
    MSG_REQ_ERROR,
    MSG_REQ_TOO_FAST_ERROR,
    USER_NOT_REGISTER,
    MSG_CODE_ERROR,
    AUTH_PASSWORD_ERROR,
    AUTH_USER_EXIST,
}
*/
